package com.csce.domain.entity.score;

import com.csce.domain.entity.go_score.GoScoreExExamScore;
import com.doudou.core.number.DecimalUtil;
import com.osce.common.annotation.Excel;
import com.osce.common.core.entity.BaseEntity;
import lombok.*;

import java.math.BigDecimal;

/**
 * 评分表步骤管理对象 score_sheet_step
 *
 * @author zzx
 * @since 2023-08-16
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
@ToString
@EqualsAndHashCode(callSuper = true)
public class ScoreSheetStep extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    private Long id;

    /**
     * 评分表编号
     */
    private Long sheetId;

    /**
     * 顺序
     */
    @Excel(name = "顺序", prompt = "可以为空")
    private String order;

    /**
     * 步骤
     */
    @Excel(name = "步骤")
    private String step;

    /**
     * 分数
     */
    @Excel(name = "分数")
    private BigDecimal score;

    /**
     * 考试分数
     */
    private BigDecimal mark;

    /**
     * 是否需要分数
     * 导入时如果分数为Null，该字段生效
     * 1 需要， 2不需要
     */
    private Integer needScore = 1;

    public void parseNeedScore(){
        if (DecimalUtil.isZero(this.score)){
            this.needScore = 2;
            this.score = null;
        }
    }


    public GoScoreExExamScore createGoScoreExExamScore(){
        GoScoreExExamScore goScoreExExamScore = new GoScoreExExamScore();
        goScoreExExamScore.setStepId(this.id);
        goScoreExExamScore.setScore(this.mark);
        return goScoreExExamScore;
    }
}
